﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GoogleSchemeTileLoader
{
    public class XytoColRow
    {
        /// <summary>
        /// 获取列号
        /// </summary>
        /// <param name="OrginX">坐标原点X</param>
        /// <param name="x">平面坐标x</param>
        /// <param name="tileSize">切片大小</param>
        /// <param name="resolution">分辨率</param>
        /// <returns></returns>
        public static int getCol(double OrginX, double x, int tileSize, double resolution)
        {
            int col = (int)Math.Floor((Math.Abs(OrginX - x)) / (tileSize * resolution));
            return col;
        }

        /// <summary>
        /// 获取行号s
        /// </summary>
        /// <param name="OrginY">坐标原点Y</param>
        /// <param name="y">平面坐标y</param>
        /// <param name="tileSize">瓦片大小</param>
        /// <param name="resolution">分辨率</param>
        /// <returns></returns>
        public static int getRow(double OrginY, double y, int tileSize, double resolution)
        {
            int row = (int)Math.Floor((Math.Abs(OrginY - y)) / (tileSize * resolution));
            return row;
        }
    }
}
